<script lang="ts">
import { defineComponent, PropType } from 'vue'

export default defineComponent({
  name: 'm-button',
  props: {
    type: {
      type: String as PropType<'primary' | 'warning' | 'danger' | ''>,
      default: '',
    },
    vanish: {
      type: Boolean,
      default: false,
    },
    disabled: {
      type: Boolean,
      default: false,
    },
  },
})
</script>

<template>
  <button
    type="button"
    class="many-btn"
    v-bind="$attrs"
    :data-style="type"
    :class="{ vanish }"
    :disabled="disabled"
  >
    <slot />
  </button>
</template>

<style scoped lang="scss">
.many-btn {
  --shadow-color: 3px 3px 3px 0 rgba(0, 0, 0, 0.5);
  --shadow-color-inset: 0 3px 6px 0 rgba(255, 255, 255, 1) inset;
  --shadow-color-inset2: 0 -3px 6px 0 rgba(0, 0, 0, 0.8) inset;

  flex-shrink: 0;
  border-radius: 10px;
  background: #ddeaff;
  color: #161930;
  font-size: 22px;
  display: inline-flex;
  text-align: center;
  align-items: center;
  justify-content: center;
  border: none;
  width: 150px;
  height: 60px;
  box-shadow: var(--shadow-color-inset), var(--shadow-color-inset2),
    var(--shadow-color);
  transition: all 0.25s ease-in-out;
  font-weight: bold;
  text-shadow: 0 0 1px rgba(0, 0, 0, 0.5);

  &:active {
    background: var(--primary-color);
  }

  &[disabled] {
    cursor: not-allowed;
    filter: grayscale(1);
    opacity: 0.8;

    &:active {
      background: #ddeaff;
    }

    &[data-style='warning'] {
      &:active {
        background: #f6b979;
      }
    }
  }

  &[data-style='primary'] {
    background: var(--primary-color);
  }

  &[data-style='danger'] {
    background: #f12c3b;
    color: #ffffff;
  }

  &[data-style='warning'] {
    background: #f6b979;
    color: #ffffff;

    &:active {
      background: #f12c3b;
      color: #ffffff;
    }
  }

  &.vanish {
    pointer-events: none;
    opacity: 0;
    width: 0;
  }
}
</style>
